//
//  WmcSelectTitleView.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/3/4.
//

import UIKit

class WmcSelectTitleView: WmcBaseView {
    lazy var leftBtn: UIButton = {
        let btn = UIButton()

        return btn
    }()

    lazy var rightBtn: UIButton = {
        let btn = UIButton()

        return btn
    }()

    lazy var titleLabel: UILabel = {
        let label = UILabel.YP.Create(font: 16.yp.uiFont(weight: .medium),
                                      color: UIColor.wmc_grayH2_323233,
                                      alignment: .center)
        return label
    }()
    

    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = .wmc_lineColor
        return view
    }()
    
    /// 标题
    var title: String? {
        set { titleLabel.text = newValue }
        get { return titleLabel.text }
    }
    
    /// 分割线
    var isShowLine: Bool = true {
        didSet { lineView.isHidden = !isShowLine }
    }

    override func makeUI() {
        addSubview(leftBtn)
        leftBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(Wmc_standardEdge.left)
            make.size.equalTo(24)
        }
        addSubview(rightBtn)
        rightBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(-Wmc_standardEdge.right)
            make.size.equalTo(leftBtn)
        }

        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.bottom.centerX.equalToSuperview()
            make.left.greaterThanOrEqualTo(leftBtn.snp.right).offset(8)
            make.right.lessThanOrEqualTo(rightBtn.snp.right).offset(-8)
        }
        
        addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.bottom.left.right.equalToSuperview()
            make.height.equalTo(0.5)
        }
    }
}
